﻿using Cemit.PolyProto;
using Google.Protobuf;
using System;
using System.Collections.Generic;
using System.Text;

namespace Cemit.PolyServer
{
    public static class MessageHandleAsExtensions
    {
        /// <summary>
        /// 转换消息类型
        /// </summary>
        public static T AsMessage<T>(this IMessageHandle<T> messageHandle, IMessage message) where T : IMessage
        {
            return (T)message;
        }

        /// <summary>
        /// 转换消息类型
        /// </summary>
        public static T AsMessage<T>(this IAsyncGetHandle<T> messageHandle, G message) where T : IMessage, new()
        {
            return message.Msg.Unpack<T>();
        }
    }
}
